import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:shop/login/login.dart';
import 'package:shop/page/root_page.dart';

import 'login/forget_pwd.dart';
import 'login/reset_pwd.dart';

final routes = {
  // '/root': (context) => RootPage(),
  '/login': (context, {arguments}) => LoginPage(),
  '/forgetpwd': (context) => ForgetPwdPage(),
  '/root': (context) => RootPage(),
  '/resetpwd': (context, {arguments}) => ResetPwdPage(params: arguments),
};

final onGenerateRoute = (RouteSettings settings) {
  final String name = settings.name!;
  final Function? pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route<dynamic> route =
          CupertinoPageRoute(builder: (context) => pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route<dynamic> route = CupertinoPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
  return null;
};
